﻿using System;
using System.Windows;
using Kiva7.Utilities;

namespace Kiva7.Pages
{
    public partial class WebBrowserPage
    {
        private const string BrowserUrlKey = "urlID";


        private const string Url = "/Pages/WebBrowserPage.xaml";

        public static Uri GetPageUrl(string browserUrl)
        {
            UrlCreator url = new UrlCreator(Url);
            url.Add(BrowserUrlKey, browserUrl);

            return url.ToUri(UriKind.RelativeOrAbsolute);
        }

        public WebBrowserPage()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPageLoaded(object sender, RoutedEventArgs e)
        {
            if (NavigationService.CanGoForward)
            {
                NavigationService.GoBack();
            }
            else
            {
                webBrowser.Navigate(new Uri(NavigationContext.GetQueryString(BrowserUrlKey)));
            }
        }
    }
}